<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="angular1.2.15.js"></script>
</head>
<body ng-app="app" ng-controller="app">
<div class="box" style="margin-top: 100px">
    <textarea id="test" style="width: 200px;height: 50px" ng-change="ch()" ng-model="val"></textarea>
    <span>{{val?val.length:0}}</span>
</div>
<script>
    var app = angular.module('app',[]);
    app.controller('app',['$scope',function ($scope) {
        $scope.num = 0
        $scope.ch = function () {
            console.log('1');
            if ($scope.val.length > 5) {
                $scope.val = $scope.val.substr(0, 5);
            }
        }

    }])

</script>

</body>
</html>